home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / advancec.arc / UIS.ARC / DISPLAY.C < prev    next >
Text File  |  1992-01-24  |  4KB  |  195 lines

  1. /*
  2.     display.c
  3.  
  4.     miscellaneous display routines
  5. */
  6.  
  7. #include "usrif.h"
  8. #undef   NULL
  9. #include <ctype.h>
  10. #include <stdio.h>
  11.  
  12. /*
  13.     #include system-dependent header files here
  14. */
  15.  
  16. /* globals */
  17. extern  rect_t  screen;
  18. extern  vport_t *the_port;
  19.  
  20. /* desktop segment pointers */
  21. seg_t   *desk_seg = NULL;
  22. seg_t   *trash;
  23.  
  24. /* current and last cursor positions */
  25. point_t cursor,
  26.         last_loc;
  27.  
  28. int     erase = FALSE;
  29.  
  30. /* cursor operations */
  31.  
  32. /* set new cursor position */
  33. void    set_cursor(loc)
  34. point_t *loc;
  35. {
  36.     void xor_cursor();
  37.  
  38.     if(erase == FALSE)
  39.         {
  40.         erase = TRUE;
  41.         last_loc.x = loc->x;
  42.         last_loc.y = loc->y;
  43.         xor_cursor(loc);
  44.         }
  45.     else if( (last_loc.x != loc->x) || (last_loc.y != loc->y) )
  46.         {
  47.         xor_cursor(&last_loc);
  48.         last_loc.x = loc->x;
  49.         last_loc.y = loc->y;
  50.         xor_cursor(loc);
  51.         }
  52.     cursor.x = loc->x;
  53.     cursor.y = screen.top - loc->y;
  54. }
  55.  
  56. /* get current cursor position */
  57. void    get_cursor( pt )
  58. point_t *pt;
  59. {
  60.     if(pt == NULL)
  61.         return;
  62.  
  63.     pt->x = cursor.x;
  64.     pt->y = cursor.y;
  65. }
  66.  
  67. /*
  68.     cursor hide and show functions
  69. */
  70.  
  71. int view_status = FALSE;
  72.  
  73. void    hide_cursor()
  74. {
  75.     void xor_cursor();
  76.  
  77.     if(view_status == FALSE)
  78.         {
  79.         xor_cursor(&last_loc);
  80.         erase = FALSE;
  81.         }
  82.     view_status++;
  83. }
  84.  
  85. void    show_cursor()
  86. {
  87.     point_t loc;
  88.  
  89.     if(view_status == 1)
  90.         {
  91.         loc.x = cursor.x;
  92.         loc.y = screen.top - cursor.y;
  93.         set_cursor(&loc);
  94.         }
  95.     --view_status;
  96. }
  97.  
  98. /*
  99.     cursor drawing functions
  100. */
  101.  
  102. void    xor_cursor(loc)
  103. point_t *loc;
  104. {
  105. /*
  106.     exclusive OR the current cursor
  107.     in the bit map at location 'loc'
  108. */
  109. }
  110.  
  111. /* desktop operations */
  112.  
  113. /* make desktop */
  114. void    make_desktop()
  115. {
  116.     /* trash icon */
  117.     cr_seg("trash");
  118.         add_attr(RESET);
  119.         add_attr(NOFILL);
  120.         add_attr(BLACK);
  121.  
  122.         rect(7,1,25,24);
  123.         rect(6,24,26,26);
  124.         rect(13,26,19,28);
  125.  
  126.         begin_line();
  127.             con_point(10,3);
  128.             con_point(10,22);
  129.         add_line(end_line());
  130.  
  131.         begin_line();
  132.             con_point(13,3);
  133.             con_point(13,22);
  134.         add_line(end_line());
  135.  
  136.         begin_line();
  137.             con_point(19,3);
  138.             con_point(19,22);
  139.         add_line(end_line());
  140.  
  141.         begin_line();
  142.             con_point(22,3);
  143.             con_point(22,22);
  144.         add_line(end_line());
  145.  
  146.         text("Trash", 16, 0, MIDDLE , TOP);
  147.     trash = cl_seg();
  148.  
  149.     cr_seg("desk_top");
  150.         add_attr(RESET);
  151.  
  152.         /* desktop background of white */
  153.         add_attr(FILL);
  154.         add_rect(&screen);
  155.         ref("trash" ,screen.right-70,20,NULL);
  156.  
  157.     desk_seg = cl_seg();
  158. }
  159.  
  160. #define CANCEL  0
  161. #define PRINT   1
  162. #define CLALL   2
  163. #define QUIT    3
  164.  
  165. char    *desk_ops[4] =
  166.     {
  167.     "Cancel",
  168.     "Print",
  169.     "Close All",
  170.     "Quit"
  171.     };
  172.  
  173. void    desktop(event)
  174. event_t     *event;
  175. {
  176. int sel;
  177.  
  178.     if(event->what == DN_BUTTON_EVENT)
  179.         {
  180.         sel = pop_up_menu( 4, desk_ops );
  181.  
  182.         switch(sel)
  183.             {
  184.             case  CANCEL  : /* nothing */   break;
  185.             case  PRINT   : print_screen(); break;
  186.             case  CLALL   : purge_all();    break;
  187.             case  QUIT    : exit();
  188.             }
  189.         }
  190.     else if(event->what == KEY_EVENT)
  191.         {
  192.         /* perform desktop key function */
  193.         }
  194. }
  195.